home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / X11R4 / cmds / X / ddx / Xsun / diffs < prev    next >
Encoding:
Text File  |  1991-11-23  |  12.4 KB  |  440 lines

  1. *** /tmp/,RCSt1725321    Fri Nov 22 18:45:20 1991
  2. --- sunMouse.c    Sun Apr 22 23:36:35 1990
  3. ***************
  4. *** 73,79 ****
  5.   
  6.   static void           sunMouseCtrl();
  7.   static int           sunMouseGetMotionEvents();
  8. ! static Firm_event     *sunMouseGetEvents();
  9.   static void           sunMouseProcessEvent();
  10.   static void           sunMouseDoneEvents();
  11.   
  12. --- 73,79 ----
  13.   
  14.   static void           sunMouseCtrl();
  15.   static int           sunMouseGetMotionEvents();
  16. ! static Mouse_Event     *sunMouseGetEvents();
  17.   static void           sunMouseProcessEvent();
  18.   static void           sunMouseDoneEvents();
  19.   
  20. ***************
  21. *** 108,113 ****
  22. --- 108,116 ----
  23.    *    keyboard.  We have arbitrarily chosen to enable and disable windowFd
  24.    *    in the keyboard routine sunKbdProc rather than in sunMouseProc.
  25.    *
  26. +  *    In Sprite, things work like under suntools, in that /dev/mouse
  27. +  *    handles both mouse and keyboard.
  28. +  *
  29.    *-----------------------------------------------------------------------
  30.    */
  31.   int
  32. ***************
  33. *** 127,151 ****
  34.           return (!Success);
  35.           }
  36.   
  37. -         if (! sunUseSunWindows()) {
  38. -         if (sysMousePriv.fd >= 0) {
  39. -             fd = sysMousePriv.fd;
  40. -         } else {
  41. -             fd = open ("/dev/mouse", O_RDWR, 0);
  42. -             if (fd < 0) {
  43. -             Error ("Opening /dev/mouse");
  44. -             return (!Success);
  45. -             }
  46. -             if (fcntl (fd, F_SETFL, (FNDELAY|FASYNC)) < 0
  47. -             || fcntl(fd, F_SETOWN, getpid()) < 0) {
  48. -                 perror("sunMouseProc");
  49. -                 ErrorF("Can't set up mouse on fd %d\n", fd);
  50. -             }
  51. -             
  52. -             sysMousePriv.fd = fd;
  53. -         }
  54. -         }
  55.           sunMousePriv.bmask = 0;
  56.           sunMousePriv.mouseMoved = FALSE;
  57.           sysMousePriv.dx = 0;
  58. --- 130,135 ----
  59. ***************
  60. *** 161,198 ****
  61.           break;
  62.   
  63.       case DEVICE_ON:
  64. -         if (! sunUseSunWindows()) {
  65. -         if (ioctl (((PtrPrivPtr)pMouse->devicePrivate)->fd,
  66. -             VUIDGFORMAT, &oformat) < 0) {
  67. -             Error ("VUIDGFORMAT");
  68. -             return(!Success);
  69. -         }
  70. -         format = VUID_FIRM_EVENT;
  71. -         if (ioctl (((PtrPrivPtr)pMouse->devicePrivate)->fd,
  72. -             VUIDSFORMAT, &format) < 0) {
  73. -             Error ("VUIDSFORMAT");
  74. -             return(!Success);
  75. -         }
  76. -         AddEnabledDevice (((PtrPrivPtr)pMouse->devicePrivate)->fd);
  77. -         }
  78.           pMouse->on = TRUE;
  79.           break;
  80.   
  81.       case DEVICE_CLOSE:
  82. -         if (! sunUseSunWindows()) {
  83. -         if (ioctl (((PtrPrivPtr)pMouse->devicePrivate)->fd,
  84. -             VUIDSFORMAT, &oformat) < 0) {
  85. -             Error ("VUIDSFORMAT");
  86. -         }
  87. -         }
  88.           break;
  89.   
  90.       case DEVICE_OFF:
  91.           pMouse->on = FALSE;
  92. -         if (! sunUseSunWindows()) {
  93. -         RemoveEnabledDevice (((PtrPrivPtr)pMouse->devicePrivate)->fd);
  94. -         }
  95.           break;
  96.       }
  97.       return (Success);
  98. --- 145,158 ----
  99. ***************
  100. *** 250,256 ****
  101.    *    Return the events waiting in the wings for the given mouse.
  102.    *
  103.    * Results:
  104. !  *    A pointer to an array of Firm_events or (Firm_event *)0 if no events
  105.    *    The number of events contained in the array.
  106.    *    A boolean as to whether more events might be available.
  107.    *
  108. --- 210,216 ----
  109.    *    Return the events waiting in the wings for the given mouse.
  110.    *
  111.    * Results:
  112. !  *    A pointer to an array of Mouse_Events or (Mouse_Event *)0 if no events
  113.    *    The number of events contained in the array.
  114.    *    A boolean as to whether more events might be available.
  115.    *
  116. ***************
  117. *** 258,290 ****
  118.    *    None.
  119.    *-----------------------------------------------------------------------
  120.    */
  121. ! static Firm_event *
  122. ! sunMouseGetEvents (pMouse, pNumEvents, pAgain)
  123.       DevicePtr      pMouse;        /* Mouse to read */
  124.       int              *pNumEvents;        /* Place to return number of events */
  125. -     Bool      *pAgain;        /* whether more might be available */
  126.   {
  127. !     int              nBytes;        /* number of bytes of events available. */
  128. !     register PtrPrivPtr      pPriv;
  129. !     static Firm_event    evBuf[MAXEVENTS];   /* Buffer for Firm_events */
  130. !     pPriv = (PtrPrivPtr) pMouse->devicePrivate;
  131. !     nBytes = read (pPriv->fd, evBuf, sizeof(evBuf));
  132. !     if (nBytes < 0) {
  133. !     if (errno == EWOULDBLOCK) {
  134. !         *pNumEvents = 0;
  135. !         *pAgain = FALSE;
  136. !     } else {
  137. !         Error ("Reading mouse");
  138. !         FatalError ("Could not read from mouse");
  139. !     }
  140. !     } else {
  141. !     *pNumEvents = nBytes / sizeof (Firm_event);
  142. !     *pAgain = (nBytes == sizeof (evBuf));
  143. !     }
  144. !     return (evBuf);
  145.   }
  146.   
  147.   
  148. --- 218,229 ----
  149.    *    None.
  150.    *-----------------------------------------------------------------------
  151.    */
  152. ! static Mouse_Event *
  153. ! sunMouseGetEvents (pMouse, pNumEvents)
  154.       DevicePtr      pMouse;        /* Mouse to read */
  155.       int              *pNumEvents;        /* Place to return number of events */
  156.   {
  157. !     return (Mouse_Event *)0;
  158.   }
  159.   
  160.   
  161. ***************
  162. *** 336,399 ****
  163.    *-----------------------------------------------------------------------
  164.    */
  165.   static void
  166. ! sunMouseProcessEvent (pMouse, fe)
  167.       DevicePtr      pMouse;       /* Mouse from which the event came */
  168. !     Firm_event      *fe;            /* Event to process */
  169.   {
  170.       xEvent        xE;
  171.       register PtrPrivPtr    pPriv;    /* Private data for pointer */
  172.       register SunMsPrivPtr pSunPriv; /* Private data for mouse */
  173.       register int      bmask;    /* Temporary button mask */
  174.   
  175.       pPriv = (PtrPrivPtr)pMouse->devicePrivate;
  176.       pSunPriv = (SunMsPrivPtr) pPriv->devPrivate;
  177.   
  178. !     xE.u.keyButtonPointer.time = TVTOMILLI(fe->time);
  179. !     switch (fe->id)
  180. !     {
  181. !     case MS_LEFT:
  182. !     case MS_MIDDLE:
  183. !     case MS_RIGHT:
  184. !     /*
  185. !      * A button changed state. Sometimes we will get two events
  186. !      * for a single state change. Should we get a button event which
  187. !      * reflects the current state of affairs, that event is discarded.
  188. !      *
  189. !      * Mouse buttons start at 1.
  190. !      */
  191. !     xE.u.u.detail = (fe->id - MS_LEFT) + 1;
  192. !     bmask = 1 << xE.u.u.detail;
  193. !     if (fe->value == VKEY_UP) {
  194. !         if (pSunPriv->bmask & bmask) {
  195. !         xE.u.u.type = ButtonRelease;
  196. !         pSunPriv->bmask &= ~bmask;
  197. !         } else {
  198. !         return;
  199. !         }
  200. !     } else {
  201. !         if ((pSunPriv->bmask & bmask) == 0) {
  202. !         xE.u.u.type = ButtonPress;
  203. !         pSunPriv->bmask |= bmask;
  204. !         } else {
  205. !         return;
  206. !         }
  207. !     }
  208. !     /*
  209. !      * If the mouse has moved, we must update any interested client
  210. !      * as well as DIX before sending a button event along.
  211. !      */
  212. !     if (pSunPriv->mouseMoved) {
  213. !         sunMouseDoneEvents (pMouse, FALSE);
  214. !     }
  215.       
  216. -     miPointerPosition (screenInfo.screens[0],
  217. -                &xE.u.keyButtonPointer.rootX,
  218. -                &xE.u.keyButtonPointer.rootY);
  219. -     
  220. -     (* pMouse->processInputProc) (&xE, pMouse, 1);
  221. -     break;
  222. -     case LOC_X_DELTA:
  223.       /*
  224.        * When we detect a change in the mouse coordinates, we call
  225.        * the cursor module to move the cursor. It has the option of
  226. --- 275,296 ----
  227.    *-----------------------------------------------------------------------
  228.    */
  229.   static void
  230. ! sunMouseProcessEvent (pMouse, ev)
  231.       DevicePtr      pMouse;       /* Mouse from which the event came */
  232. !     Mouse_Event      *ev;            /* Event to process */
  233.   {
  234.       xEvent        xE;
  235.       register PtrPrivPtr    pPriv;    /* Private data for pointer */
  236.       register SunMsPrivPtr pSunPriv; /* Private data for mouse */
  237.       register int      bmask;    /* Temporary button mask */
  238. +     register int      button;
  239.   
  240.       pPriv = (PtrPrivPtr)pMouse->devicePrivate;
  241.       pSunPriv = (SunMsPrivPtr) pPriv->devPrivate;
  242.   
  243. !     xE.u.keyButtonPointer.time = ev->time;
  244. !     bmask = ev->key ^ pSunPriv->bmask;
  245.   
  246.       /*
  247.        * When we detect a change in the mouse coordinates, we call
  248.        * the cursor module to move the cursor. It has the option of
  249. ***************
  250. *** 403,438 ****
  251.        * What should be done if it goes off the screen? Move to another
  252.        * screen? For now, we just force the pointer to stay on the
  253.        * screen...
  254. !      */
  255. !     pPriv->dx += MouseAccelerate (pMouse, fe->value);
  256. ! #ifdef    SUN_ALL_MOTION
  257. !     miPointerDeltaCursor (screenInfo.screens[0], pPriv->dx, pPriv->dy, TRUE);
  258. !     pPriv->dx = 0;
  259. !     pPriv->dy = 0;
  260. ! #else
  261. !     ((SunMsPrivPtr)pPriv->devPrivate)->mouseMoved = TRUE;
  262. ! #endif
  263. !     break;
  264. !     case LOC_Y_DELTA:
  265. !     /*
  266.        * For some reason, motion up generates a positive y delta
  267.        * and motion down a negative delta, so we must subtract
  268.        * here instead of add...
  269.        */
  270. !     pPriv->dy -= MouseAccelerate (pMouse, fe->value);
  271. ! #ifdef SUN_ALL_MOTION
  272. !     miPointerDeltaCursor (screenInfo.screens[0], pPriv->dx, pPriv->dy, TRUE);
  273. !     pPriv->dx = 0;
  274. !     pPriv->dy = 0;
  275. ! #else
  276.       ((SunMsPrivPtr)pPriv->devPrivate)->mouseMoved = TRUE;
  277. ! #endif SUN_ALL_MOTION
  278. !     break;
  279. !     default:
  280. !     FatalError ("sunMouseProcessEvent: unrecognized id\n");
  281. !     break;
  282.       }
  283.   }
  284.   
  285.   /*ARGSUSED*/
  286. --- 300,339 ----
  287.        * What should be done if it goes off the screen? Move to another
  288.        * screen? For now, we just force the pointer to stay on the
  289.        * screen...
  290. !      *
  291.        * For some reason, motion up generates a positive y delta
  292.        * and motion down a negative delta, so we must subtract
  293.        * here instead of add...
  294.        */
  295. !     if (ev->deltaX) {
  296. !         pPriv->dx += MouseAccelerate (pMouse, ev->deltaX);
  297.           ((SunMsPrivPtr)pPriv->devPrivate)->mouseMoved = TRUE;
  298. !     }
  299. !     if (ev->deltaY) {
  300. !         pPriv->dy -= MouseAccelerate (pMouse, ev->deltaY);
  301. !         ((SunMsPrivPtr)pPriv->devPrivate)->mouseMoved = TRUE;
  302. !     }
  303. !     if (ev->key ^ pSunPriv->bmask) {
  304. !     sunMouseDoneEvents (pMouse, FALSE);
  305. !     }
  306. !     xE.u.keyButtonPointer.time = ev->time;
  307. !     for (bmask = 4, button = 1; bmask != 0; bmask >>= 1, button++) {
  308. !     if ((ev->key & bmask) != (pSunPriv->bmask & bmask)) {
  309. !         xE.u.u.type = (ev->key & bmask) ? ButtonRelease : ButtonPress;
  310. !         xE.u.u.detail = button;
  311. !         miPointerPosition (screenInfo.screens[0],
  312. !         &xE.u.keyButtonPointer.rootX,
  313. !         &xE.u.keyButtonPointer.rootY);
  314. !         (* pMouse->processInputProc) (&xE, pMouse, 1);
  315. !     }
  316.       }
  317. +     pSunPriv->bmask = ev->key;
  318. +     lastEventTime = ev->time;
  319.   }
  320.   
  321.   /*ARGSUSED*/
  322. ***************
  323. *** 483,489 ****
  324.       ScreenPtr    pScreen;
  325.       Bool    entering;
  326.   {
  327. !     u_char  select;
  328.   
  329.       select = 1;
  330.       if (entering)
  331. --- 384,390 ----
  332.       ScreenPtr    pScreen;
  333.       Bool    entering;
  334.   {
  335. !     unsigned char  select;
  336.   
  337.       select = 1;
  338.       if (entering)
  339. ***************
  340. *** 530,615 ****
  341.       miPointerDeltaCursor (screenInfo.screens[0], dx, dy, TRUE);
  342.       }
  343.   }
  344. - #ifdef SUN_WINDOWS
  345. - /*
  346. -  * Process a sunwindows mouse event.  The possible events are
  347. -  *   LOC_MOVE
  348. -  *   MS_LEFT
  349. -  *   MS_MIDDLE
  350. -  *   MS_RIGHT
  351. -  */
  352. - void
  353. - sunMouseProcessEventSunWin(pMouse,se)
  354. -     DeviceRec *pMouse;
  355. -     register struct inputevent *se;
  356. - {   
  357. -     xEvent            xE;
  358. -     register int          bmask;    /* Temporary button mask */
  359. -     register PtrPrivPtr        pPriv;    /* Private data for pointer */
  360. -     register SunMsPrivPtr    pSunPriv; /* Private data for mouse */
  361. -     short            x, y;
  362. -     pPriv = (PtrPrivPtr)pMouse->devicePrivate;
  363. -     switch (event_id(se)) {
  364. -         case MS_LEFT:
  365. -         case MS_MIDDLE:
  366. -         case MS_RIGHT:
  367. -         /*
  368. -          * A button changed state. Sometimes we will get two events
  369. -          * for a single state change. Should we get a button event which
  370. -          * reflects the current state of affairs, that event is discarded.
  371. -          *
  372. -          * Mouse buttons start at 1.
  373. -          */
  374. -         pSunPriv = (SunMsPrivPtr) pPriv->devPrivate;
  375. -         xE.u.keyButtonPointer.time = TVTOMILLI(event_time(se));
  376. -         xE.u.u.detail = (event_id(se) - MS_LEFT) + 1;
  377. -         bmask = 1 << xE.u.u.detail;
  378. -         if (win_inputnegevent(se)) {
  379. -         if (pSunPriv->bmask & bmask) {
  380. -             xE.u.u.type = ButtonRelease;
  381. -             pSunPriv->bmask &= ~bmask;
  382. -         } else {
  383. -             return;
  384. -         }
  385. -         } else {
  386. -         if ((pSunPriv->bmask & bmask) == 0) {
  387. -             xE.u.u.type = ButtonPress;
  388. -             pSunPriv->bmask |= bmask;
  389. -         } else {
  390. -             return;
  391. -         }
  392. -         }
  393. -         miPointerPosition (screenInfo.screens[0],
  394. -             &xE.u.keyButtonPointer.rootX, &xE.u.keyButtonPointer.rootY);
  395. -             (* pMouse->processInputProc) (&xE, pMouse, 1);
  396. -             break;
  397. -         case LOC_MOVE:
  398. -         /*
  399. -          * Tell mi to go ahead and generate the event.
  400. -          */
  401. -         miPointerMoveCursor(screenInfo.screens[0], event_x(se),
  402. -         event_y(se), TRUE);
  403. -         /*
  404. -          * Find out if the mouse got constrained. If it did
  405. -          * then we have to tell SunWindows about it.
  406. -          */
  407. -         miPointerPosition (screenInfo.screens[0], &x, &y);
  408. -         if (x != event_x(se) || y != event_y(se))
  409. -             /*
  410. -                  * Tell SunWindows that X is constraining the mouse
  411. -                  * cursor so that the server and SunWindows stay in sync.
  412. -              */
  413. -             win_setmouseposition(windowFd, x, y);
  414. -         break;
  415. -     default:
  416. -         FatalError ("sunMouseProcessEventSunWin: unrecognized id\n");
  417. -         break;
  418. -     }
  419. - }
  420. - #endif SUN_WINDOWS
  421. --- 431,433 ----
  422.